import { ref, computed, reactive } from "vue";
import { defineStore } from "pinia";
import { useRouter } from "vue-router";
import _ from "lodash";

const modules = import.meta.glob("../views/*/*/*.vue");

export const useRouteStore = defineStore("route", () => {
  const router = useRouter()
  const route = reactive({ data: [] });
  const AddRoute = (data) => {
    route.data = data;
    route.data.forEach((item) => {
      router.addRoute("Main", {
        path: item.path,
        name:item.name,
        component: modules[`../views${item.component}.vue`],
        meta: { title: item.title },
      });
    });
  };
  return { route, AddRoute };
});
